package net.neptech.util;

import cn.hutool.core.util.StrUtil;
import net.neptech.model.sys.Dept;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author Saya
 * @Date 2025/8/24 23:50
 * @Description TODO
 **/
public class DeptUtil {
    public static List<String> queryRootIdList(String deptId, List<Dept> deptList){
        if(StrUtil.isBlank(deptId)||StrUtil.equals(deptId,"0")){
            return new ArrayList<>();
        }
        List<String> list=new ArrayList<>();
        Dept oaDepartments = deptList.stream().filter(w -> w.getDeptId().toString().equals(deptId)).findFirst().orElse(null);
        String parentId = null;
        if (oaDepartments != null) {
            parentId = oaDepartments.getParentId().toString();
        }
        list.add(deptId);
        List<String> integers = queryRootIdList(parentId, deptList);
        list.addAll(integers);
        return list;
    }
}
